Auto merge of #3078 - jhbabon:fix/parse-home-config-once, r=alexcrichton
authorbors <bors@rust-lang.org>
Fri, 9 Sep 2016 16:16:01 +0000 (09:16 -0700)
committerGitHub <noreply@github.com>
Fri, 9 Sep 2016 16:16:01 +0000 (09:16 -0700)
Fix: Don't parse the home directory more than once

This PR tries to resolve this issue https://github.com/rust-lang/cargo/issues/3070. The problem is that the `walk_tree` method in the `src/util/config.rs` module was parsing more than once the contents of the config file in the home directory (the file `~/.cargo/config`). The biggest problem with this is with options that can accept multiple values, like `build.rustflags`. If you parse the file twice, the same option can end with duplicated values (e.g: `rustflags=["-Z", "foo", "-Z", "foo"]`).

I made the fix following the comments in the issue. In the fix I keep track of all the parsed config files in a `HashSet` so I can know if a file has been parsed already. ~~I'm also using `std::fs::canonicalize`, as suggested in the issue, to prevent parsing files behind symbolic links more than once.~~

**UPDATE:** I removed the call to `fs::canonicalize` as suggested in the comments. Now the fix is way simpler, which means less code and less possibilities to add a new bug.


Trivial merge